<?php
# bitmap 案例

//批量设置在线状态
$uids = range(1, 500000);
foreach ($uids as $uid) {
    $redis->setBit('online', $uid, $uid % 2);
}

//一个一个获取状态
$uids = range(1, 500000);


$startTime = microtime(true);

foreach ($uids as $uid) {
    echo $redis->getBit('online', $uid) . PHP_EOL;
}

$endTime = microtime(true);

//在我的电脑上，获取50W个用户的状态需要25秒 
echo "total:" . ($endTime - $startTime) . "s";
